#ifndef STYDATABASE_H
#define STYDATABASE_H

#include <QSqlDatabase>
#include <QDebug>
#include <QStringList>
#include <QMessageBox>
#include <QSqlQuery>
#include <QSqlError>
#include <QString>
#include <QDate>
#include <QPixmap>
#include <QMessageBox>
#include <QString>
#include <QByteArray>
#include <QFile>
#include <QBuffer>
#include <QBitArray>
#include <QTime>

struct MyDatabase {
    const char *sql_host;
    const char *sql_db_name;
    const char *sql_db_passwd;
    const char *sql_user_name;
    const int   sql_port;
};
struct DailySummary {
    QString DName;
    QDate   DDate;
    QTime   DTime;
    QString DContent;
    QString DPraise;
    QPixmap DPicture;
};

struct Users {
    QString UName;
    QString UNickname;
    QString UPassword;
    QString USex;
    QDate UBirthday;
    QString UAddress;
    QString UPhone;
    QString UEmail;
    QString ULearnGoals;    //学习目标
    QString ULearnDcla;     //学习宣言
    float UTgDayTime;       //每一天的计划学习时长
    int UTgDay;             //计划完成天数
    QDate UDeadline;        //截止日期
    QString penName;        //所拥有的"笔名"
    QPixmap UPicture;
};
struct styData{
    QVector<double> in_factData;
    QVector<double> balanceData;
    QVector<double> overfulData;
    QVector<double> actual_Data;
    struct Users friends;
};
extern QVector<struct styData> g_data;
//extern struct Users *user;

class styDatabase
{

public:
    styDatabase();
    bool userAuthenticate(QString UName,QString UPassword);
private:

public:
    static bool createConnection();
    bool inquireAllInfo(QString UName);
    bool inquireOneInfo(QString UName);
    bool friendOpt(int opt,QString FName,QString FFriName, int FRel);
    void avail_drivers();
    //struct Users user;
};
/**
 * @brief releaseDynamic 向数据表DailySummary添加一条新记录
 * @param content   日志的内容
 * @param file_name 图片文件名
 */
void releaseDynamic(QString content,QString file_name);
void getAllDailySummary(QVector<struct DailySummary> &allDailySummary);
#endif // STYDATABASE_H
